﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Framework.BootStrappers;
using Framework.Infrastructure.IoC;
using Microsoft.Practices.Unity;
using IHaveBaby.Extension;
using Framework.Event;
using Framework.Infrastructure;
using System.Collections;

namespace IHaveBaby
{
    public partial class WebApplication : System.Web.HttpApplication
    {
        IBootStrapper BootStrapper { get; set; }
        protected void Application_Start()
        {
            try
            {
                BootStrapper = IoCFactory.Instance.CurrentContainer.Resolve<IBootStrapper>();
                BootStrapper.Boot();
            }
            catch (TypeInitializationException ex)
            {

                if (ex.InnerException is System.IO.FileLoadException)
                {
                    var typeLoadException = ex.InnerException as System.IO.FileLoadException;
                    var loaderExceptions = typeLoadException.FusionLog;
                    var str = string.Empty;
                    //loaderExceptions.ForEach(le => str += le.Message + " " + le.Data.ToJson());
                    Console.WriteLine(str);
                }
            }
            
        }

        protected void Application_End()
        {
            //var eventProcesser =
            //   IoCFactory.Instance.CurrentContainer.Resolve<IEventProcesser>();

            //eventProcesser.Stop();
        }
    }
}